package net.peelmeagrape.hibernate.collections;

import net.peelmeagrape.hibernate.xmlgen.XmlAttribute;
import net.peelmeagrape.hibernate.xmlgen.XmlElement;
import net.peelmeagrape.hibernate.Column;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;

/**
 * Define the column of the foreign table that specifies the order of the elements in the list.
 * The index of an array or list is always of type integer. The mapped column contains sequential integers
 * (numbered from zero, by default).
 */
@Target({METHOD,FIELD}) @Retention(RUNTIME)
@XmlElement(name="list-index")
public @interface ListIndex
{
    Column[] columnMapping() default {};

    /**
     * The name of the column containing the index.
     */
    @XmlAttribute String column() default "";

    /**
     * The value of the index of the first item in the list.
     */
    @XmlAttribute int base() default 0;
}
